package com.zuowei.ycy.user.ui.mine.balance;

import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.RelativeSizeSpan;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.zuowei.ycy.R;
import com.zuowei.ycy.ui.BaseToolbarAty;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Created by Administrator on 2016/4/26.
 * 余额转出第一步
 */
public class BalanceZhuanchuOneAty extends BaseToolbarAty {
    @Bind(R.id.tv_balance_money)
    TextView tvBalanceMoney;
    @Bind(R.id.edit_money)
    EditText editMoney;

    private float balance;

    @Override
    public int getLayoutId() {
        return R.layout.balance_zhuanchu_one_aty;
    }

    @Override
    public void initData() {
        mToolbar.setTitle("转出");

        balance = getIntent().getFloatExtra("price", 0);

        String price = "可转出金额：" + balance;
        SpannableString msp = new SpannableString(price);
        //设置字体大小（相对值,单位：像素） 参数表示为默认字体大小的多少倍
        msp.setSpan(new RelativeSizeSpan(1.2f), 6, price.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);  //0.5f表示默认字体大小的一半
        tvBalanceMoney.setText(msp);

    }

    @Override
    public void requestData() {

    }

    @OnClick(R.id.fbtn_next)
    @Override
    public void btnClick(View view) {
        super.btnClick(view);

        String s = editMoney.getText().toString();
        if (TextUtils.isEmpty(s)){
            showToast("请先填写提现金额");
            return;
        }

        float money = Float.parseFloat(s);
        if (money>balance){
            showToast("金额不足，无法转出");
            return;
        }

        Bundle bundle = new Bundle();
        bundle.putString("money",money+"");
        startActivity(BalanceZhuanchuTwoAty.class, bundle);
    }

}
